import service from "@/api/service";
import {mixin} from "uview-plus/libs/mixin/mixin";

class Index {
  // 微信登录
  static wxLogin(data) {
    return service.request({
      url: `/wx/user/wxa6b3fbc130f00be6/wechat/login`,
      method: "post",
      data: data,
    });
  }
  // 微信登录绑定
  static wxLoginBinding(data) {
    return service.request({
      url: `/wx/user/wxa6b3fbc130f00be6/binding`,
      method: "post",
      data: data,
    });
  }
  // token超时重新登录
  static wxLoginRefresh(data) {
    return service.request({
      url: `/wx/user/wxa6b3fbc130f00be6/web/login`,
      method: "post",
      data: data,
    });
  }
  // 获取用户信息
  static getUserInfo() {
    return service.request({
      url: `/web/user/info`,
      method: "get",
    });
  }

  // 获取视频列表
  static getDeviceList() {
    return service.request({
      url: `/web/wms/videoIpc/list`,
      method: "post",
      data: {},
    });
  }

  // 获取萤石的token
  static getAccessToken() {
    return service.request({
      url: `/web/wms/videoIpc/gettoken`,
      method: "get",
      data: {},
    });
  }


  // 注销登录
  static logout() {
    return service.request({
      url: '/logout',
      method: 'get'
    })
  }
}

const install = (Vue) => {
  // 同时挂载到uni和Vue.prototype中
  // $u挂载到uni对象上
  uni.$api = Index;

  // #ifndef APP-NVUE
  // 只有vue，挂载到Vue.prototype才有意义，因为nvue中全局Vue.prototype和Vue.mixin是无效的
  Vue.config.globalProperties.$api = Index;
  Vue.mixin(mixin);
  // #endif
}

export default {
  install
}
